<%= render  :partial => "apo/navigation" %>

<div id="containerBody">

    <div class="eventCenterDiv">

        <div style="float: left;">

            <h2>
                <%=h @event.name %> <% if session[:user].admin == true %> <i><%= link_to "edit" , :action => "edit" , :id => @event %></i> <% end %>
            </h2>

            <% if (Event.isBefore(@event.date, Time.now) and @event.event_type != "Dues" and @event.event_type != "Committee")%>
                <% if (session[:user].admin or (@event.mic_id == session[:user].id and @event.event_type != "Indy Hours")) %>
                    <% if (@event.approved == false)%>
                        <% form_tag :action => "approve_event" , :id => @event  do %>
                            <h5> This event is not currently approved.  If you approve it, those who attended will get credit. </h5>
                            <%= submit_tag "Approve Event" %>
                        <% end %>
                    <% else %>
                        <% form_tag :action => "un_approve_event" , :id => @event  do %>
                        <h5> This event is currently approved.  If you un-approve it, those who attended will not get credit. </h5>
                        <%= submit_tag "Un-approve Event" %>
                        <% end %>
                    <% end %>
                <% else %>
                    <% if (@event.approved == false)%>
                        <h5> This event is not currently approved.  Members in attendance have not yet gotten credit. </h5>
                    <% else %>
                        <h5> This event is currently approved.  Members in attendance have received credit. </h5>
                    <% end %>
                <% end%>
            <% end %>

        </div>
        <div style="float: right;">
            <h2>
                <%=h "#{@event.semester}" %>
            </h2>
        </div>

    </div>

    <div class="container memberInfoContainer" style="margin-left: 4em; clear: left;">

        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Date:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Hours:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Member In Charge:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Event Type:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Maximum Attendees:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Drivers:</div>
        </div>

    </div>

    <div class="container memberInfoContainer">

        <div class="cellRow cellRow1">
            <div class="cellBlock">
                 <%=h @event.date.strftime("%A, %b %d at %I:%M %p") %>
            </div>
        </div>
        <div class="cellRow cellRow2">
            <div class="cellBlock">
                 <%=h @event.hours %>
            </div>
        </div>
        <div class="cellRow cellRow1">
            <div class="cellBlock">
                <% if @event.mic != nil %>
                     <%= link_to h("#{@event.mic.full_name}") , :action => "show" , :controller => "members", :id => @event.mic %>
                     <% if session[:user].admin or @event.mic_id == session[:user].id %>
                        <i><%= link_to "remove", :action => "mic_remove", :member_id => @event.mic, :event_id => @event.id, :id => @event %></i>
                     <% end %>
                <% elsif (@event.date.future? and (@event.event_type == "Service" or @event.event_type == "Fundraiser" or @event.event_type == "Fellowship")) %>
                     None, <i><%= link_to "Sign Up To Be MIC" , :action => "mic_signup", :member_id => session[:user].id, :event_id => @event.id, :id => @event %></i>
                <% else %>
                     None
                <% end %>
            </div>
        </div>
        <div class="cellRow cellRow2">
            <div class="cellBlock">
                <%=h @event.event_type %>
            </div>
        </div>
        <div class="cellRow cellRow1">
            <div class="cellBlock">
                <%=h @event.max_attendees %>
              </div>
        </div>
        <div class="cellRow cellRow2">
            <div class="cellBlock">
                <%=h @event.drivers %>&nbsp;
            </div>
        </div>

    </div>

    <div class="container memberInfoContainer">

        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Contact Name:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Contact Number:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Event Address:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">City:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">State/Zip:</div>
        </div>

    </div>

    <div class="container memberInfoContainer">

        <div class="cellRow cellRow1">
            <div class="cellBlock">
                <%=h @event.contact %>&nbsp;
              </div>
        </div>
        <div class="cellRow cellRow2">
            <div class="cellBlock">
                <%=h @event.contact_phone %>&nbsp;
            </div>
        </div>
        <div class="cellRow cellRow1">
            <div class="cellBlock">
                <%=h @event.address %>&nbsp;
            </div>
        </div>
        <div class="cellRow cellRow2">
            <div class="cellBlock">
                <%=h @event.city %>&nbsp;
            </div>
        </div>
        <div class="cellRow cellRow1">
            <div class="cellBlock">
                <%=h @event.state %> <%=h @event.zip %>&nbsp;
            </div>
        </div>

    </div>

    <div class="container memberInfoContainer" style="margin: 0.5em 0 0 4em; clear: both">
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Meeting Place:</div>
        </div>
        <div class="cellRow cellRowHeader">
            <div class="cellBlock">Description:</div>
        </div>
    </div>

    <div class="container memberInfoContainer" style="margin: 0.5em 0; width: 38.25em; text-align: left">
        <div class="cellRow cellRow2">
            <div class="cellBlock">
                <%=h @event.meeting_place %>&nbsp;
            </div>
        </div>
        <div class="cellRow cellRow1">
            <div class="cellBlock">
                <%=h @event.description %>&nbsp;
            </div>
        </div>
    </div>

    <div class="eventCenterDiv">

        <% if (@event.additional_service_hours > 0 or @event.additional_fundraisers > 0 or @event.additional_fellowships > 0 or @event.additional_leaderships > 0 or @event.additional_ceremonies > 0 or @event.additional_pledge_meetings > 0 or @event.additional_active_meetings > 0 or @event.additional_office_hours > 0 or @event.four_c > 0)%>

            <% counter = 0 %>

            <div class="container creditContainer" style="margin-top: 0.5em">

                <div class="cellRow cellRowHeader">
                    <div class="cellBlock">Credit Type</div>
                    <div class="cellBlock">Points</div>
                </div>

                <% if(@event.additional_service_hours > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Service Hours</div>
                        <div class="cellBlock"><%= h(@event.additional_service_hours) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if(@event.additional_leaderships > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">LDC Credits</div>
                        <div class="cellBlock"><%= h(@event.additional_leaderships) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if(@event.additional_fellowships > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Fellowship Credits</div>
                        <div class="cellBlock"><%= h(@event.additional_fellowships) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if(@event.additional_ceremonies > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Ceremony Credits</div>
                        <div class="cellBlock"><%= h(@event.additional_ceremonies) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if(@event.additional_fundraisers > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Fundraiser Credits</div>
                        <div class="cellBlock"><%= h(@event.additional_fundraisers) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if(@event.additional_active_meetings > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Active Meetings</div>
                        <div class="cellBlock"><%= h(@event.additional_active_meetings) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if(@event.additional_pledge_meetings > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Pledge Meetings</div>
                        <div class="cellBlock"><%= h(@event.additional_pledge_meetings) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if(@event.additional_office_hours > 0)%>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Office Hours</div>
                        <div class="cellBlock"><%= h(@event.additional_office_hours) %></div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if @event.four_c & 1 == 1 %>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Chapter</div>
                        <div class="cellBlock">1</div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if @event.four_c & 2 == 2 %>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Campus</div>
                        <div class="cellBlock">1</div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if @event.four_c & 4 == 4 %>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Community</div>
                        <div class="cellBlock">1</div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

                <% if @event.four_c & 8 == 8 %>

                    <div class="cellRow cellRow<%= (counter%2==0)?1:2 %>">
                        <div class="cellBlock">Country</div>
                        <div class="cellBlock">1</div>
                    </div>
                    <% counter = counter + 1 %>

                <% end %>

            </div>

        <% end %>

        <% if (session[:user].admin or (@event.mic_id == session[:user].id and @event.event_type != "Indy Hours")) and Event.isBefore(Time.now, @event.date) %>

            <% form_tag :action => "add_attendee", :id => params[:id] do %>

                <%= text_field_with_auto_complete :member, :full_name, {}, :url => {:controller => "members", :action => "complete" }, :skip_style => true %>

                <% if @attendees - (@drivers > @event.drivers ? @event.drivers : @drivers) < @event.max_attendees - @event.drivers %>
                    <%= submit_tag "Add as attendee"%>
                <% elsif @event.event_type != "Committee" %>
                    <%= submit_tag "Add to waitlist"%>
                <% end %>
<!--                 if @event.event_type == "Service" or @event.event_type == "Fellowship" or @event.event_type == "Leadership" or @event.event_type == "Fundraiser" or @event.event_type == "Other" -->
                <% if @event.drivers > 0 %>
                  <% if @attendees < @event.max_attendees %>
                    <% if @drivers < @event.drivers %>
                      <%= submit_tag "Add as driver"%>
                    <% end %>
                  <% elsif @event.event_type != "Committee" %>
                    <%= submit_tag "Add to waitlist as driver"%>
                  <% end %>
                <% end %>

            <% end %>

        <% elsif (session[:user].admin or (@event.mic_id == session[:user].id and @event.event_type != "Indy Hours")) and !Event.isBefore(Time.now, @event.date) %>

            <% form_tag :action => "add_attendee", :id => params[:id] do %>

                <%= text_field_with_auto_complete :member, :full_name, {}, :url => {:controller => "members", :action => "complete" }, :skip_style => true %>

                <%= submit_tag "Add attendee"%>

            <% end %>

        <% elsif ((Event.isBefore(Time.now, @event.date)) and AttendanceRecord.find(:all, :conditions => {:event_id => @event, :member_id => session[:user]}).size == 0 and @event.event_type != "Dues" and @event.event_type != "Office Hour") %>

            <% form_tag :action => "add_current_user" , :id => params[:id], :member_id => session[:user] do %>

                <% if @attendees - (@drivers > @event.drivers ? @event.drivers : @drivers) < @event.max_attendees - @event.drivers %>
                    <%= submit_tag "Sign up for this event"%>
                <% elsif @event.event_type != "Committee" %>
                    <%= submit_tag "Sign up for the waitlist"%>
                <% end %>
<!--                 if @event.event_type == "Service" or @event.event_type == "Fellowship" or @event.event_type == "Leadership" or @event.event_type == "Fundraiser" or @event.event_type == "Other" -->
                <% if @event.drivers > 0 %>
                  <% if @attendees < @event.max_attendees %>
                    <% if @drivers < @event.drivers %>
                      <%= submit_tag "Sign up as driver"%>
                    <% end %>
                  <% elsif @event.event_type != "Committee" %>
                    <%= submit_tag "Sign up for the waitlist as driver"%>
                  <% end %>
                <% end %>

            <% end %>

        <% elsif (Event.isBefore(48.hours.from_now, @event.date) and (AttendanceRecord.find(:all, :conditions => {:event_id => @event, :member_id => session[:user]}).size > 0)) %>
            <% form_tag :action => "remove_attendee" , :event_id => @event, :id => @event, :member_id => session[:user]  do %>

                <%= submit_tag "Remove yourself from this event"%>
            <% end %>

        <% else %>
            <h3> An Admin or MIC must add or remove you from this event. </h3>
        <% end %>

        <% if Event.isBefore(Time.now, @event.date) %>
            <% if AttendanceRecord.find(:all, :conditions => {:event_id => @event, :waitlist => 0}).size >= @event.max_attendees %>
                <h3> This Event Is Full. </h3>
            <% end %>

            <a href="http://www.google.com/calendar/event?action=TEMPLATE&text=<%=h @event.name %>&dates=<%=h @event.date.strftime('%Y%m%dT%H%M%S/') %><%=h (@event.date+(@event.hours*3600)).strftime('%Y%m%dT%H%M%S') %>&location=<%=h @event.meeting_place %>&details=<%=h @event.description %>&trp=true&sprop=website:http://www.apouiuc.com&sprop=name:APO UIUC" target="_blank">
                <i><b>Add this event to your Google Calendar!</b></i>
            </a>
        <% end %>

        <% if @event.event_type != "Office Hour" and @event.event_type != "Dues" and @event.event_type != "Committee" %>
            <% form_tag :action => "print", :target => "_blank", :id => @event do %>
                <h3> Members in Attendance <%= submit_tag "Print Attendance Sheet"%></h3>
            <% end %>
        <% end %>

        <% form_tag :action => "update_attendees", :event_id => @event.id, :id => @event do %>

          <% if ((session[:user].admin) or (session[:user].id == @event.mic_id)) %>
            <p>
              <%= button_to_remote "Replace member", {:url => {:action => "show_replace", :id => @event}}, {:id => "replaceButton"} %>
              <% if ((session[:user].admin) or (session[:user].id == @event.mic_id and Event.isBefore(2.days.from_now, @event.date))) %>
                <%= submit_tag "Remove selected" %>
              <% end %>
                <% if Event.isBefore(@event.date, Time.now) %>
                  <% if @event.event_type != "Committee" and @event.event_type != "Dues" and @event.event_type != "Dues (late)" and @event.event_type != "Indy Hours" and @event.event_type != "Office Hour" %>
                    <%= submit_tag "Did not show up" %>
                  <% end %>
                <% end %>
                <% if @event.event_type == "Committee" %>
                  <%= submit_tag "Completed Requirements" %>
                <% end %>
            </p>
          <% end %>

          <div class="container attendeeContainer">

              <div class="cellRow cellRowHeader">
                  <div class="cellBlock">#</div>
                  <div class="cellBlock">Attendee</div>
                  <div class="cellBlock">Email</div>
                  <div class="cellBlock" style="text-align: right;">Phone Number</div>
                  <% if (@event.event_type == "Service" or @event.event_type == "Indy Hours" or @event.event_type == "Office Hour")%>
                    <% if Event.isBefore(@event.date, Time.now) %>
                      <div class="cellBlock" style="text-align: right;">Additional Hours</div>
                    <% end %>
                  <% end %>
                  <% if (@event.event_type == "Service" or @event.event_type == "Fellowship" or @event.event_type == "Leadership" or @event.event_type == "Fundraiser" or @event.event_type == "Other" or (@event.event_type == "Pledge Req" and @event.drivers > 0)) %>
                      <div class="cellBlock">Driver</div>
                  <% end %>
                  <% if Event.isBefore(@event.date, Time.now) %>
                    <% if @event.event_type != "Committee" and @event.event_type != "Dues" and @event.event_type != "Dues (late)" and @event.event_type != "Indy Hours" and @event.event_type != "Office Hour" %>
                      <div class="cellBlock">Attended</div>
                    <% end %>
                  <% end %>
                  <% if @event.event_type == "Committee" %>
                    <div class="cellBlock">Completed</div>
                  <% end %>
                  <% if ((session[:user].admin) or (session[:user].id == @event.mic_id)) %>
                      <% if (@event.event_type == "Service" or @event.event_type == "Indy Hours" or @event.event_type == "Office Hour")%>
                        <% if Event.isBefore(@event.date, Time.now) %>
                          <div class="cellBlock">&nbsp;</div>
                        <% end %>
                      <% end %>
                      <div class="cellBlock">&nbsp;</div>
                  <% end %>
              </div>

              <% row = 0 %>
  <!--              Member.find(:all, :select => "members.*", :conditions => ["members.id in (select member_id from attendance_records where event_id =#{@event.id} and waitlist = 0)"], :order => "last_name, first_name ASC").each do |member| -->

  <!--                 record = AttendanceRecord.find(:first, :conditions => {:event_id => @event, :member_id => member}) -->

              <% if (@event.event_type == "Dues" or @event.event_type == "Dues (late)" or @event.event_type == "Committee" or @event.event_type == "Office Hour" or @event.event_type == "Ceremony") or (Event.isBefore(@event.date, Time.now)) %>
                <% records = AttendanceRecord.find_all_by_event_id(@event.id, :conditions => "waitlist = 0").sort { |a,b| a.member.last_name <=> b.member.last_name } %>
              <% else %>
                <% records = AttendanceRecord.find_all_by_event_id(@event.id, :conditions => "waitlist = 0") %>
              <% end %>

              <% records.each do |record| %>

                  <% member = record.member %>

                  <div class="cellRow cellRow<%= row%2==0?1:2 %>">

                      <div class="cellBlock"><%= row + 1 %></div>
                      <div class="cellBlock"><%= link_to h(member.full_name), :controller => "members", :action => "show", :id => member %></div>
                      <div class="cellBlock"><%=h member.email %>&nbsp;</div>
                      <div class="cellBlock" style="text-align: right;"><%=h member.phone_number %>&nbsp;</div>
                      <% if (@event.event_type == "Service" or @event.event_type == "Indy Hours" or @event.event_type == "Office Hour")%>
                        <% if Event.isBefore(@event.date, Time.now) %>
                          <div class="cellBlock" style="text-align: right;"><%=h record.adjustment_hours %></div>
                        <% end %>
                      <% end %>

                      <% if (@event.event_type == "Service" or @event.event_type == "Fellowship" or @event.event_type == "Leadership" or @event.event_type == "Fundraiser" or @event.event_type == "Other" or (@event.event_type == "Pledge Req" and @event.drivers > 0)) %>

                          <% if ((session[:user].admin) or (session[:user].id == @event.mic_id) or (member.id ==session[:user].id and Event.isBefore(Time.now, @event.date))) %>
                              <% if (record.driver == false) %>
                                  <div class="cellBlock" style="text-align: center;"><%= link_to "No <i>change</i>", :action => "driver_true", :record_id => record, :event_id => @event, :id => @event %></div>
                              <% else %>
                                  <div class="cellBlock" style="text-align: center;"><%= link_to "Yes <i>change</i>", :action => "driver_false", :record_id => record, :event_id => @event, :id => @event %></div>
                              <% end %>
                          <% else %>
                              <div class="cellBlock" style="text-align: center;">
                                  <% if (record.driver)%>
                                      Yes
                                  <% else %>
                                      No
                                  <% end %>
                              </div>
                          <% end %>

                      <% end %>

                      <% if Event.isBefore(@event.date, Time.now) %>
                        <% if @event.event_type != "Committee" and @event.event_type != "Dues" and @event.event_type != "Dues (late)" and @event.event_type != "Indy Hours" and @event.event_type != "Office Hour" %>
                          <div class="cellBlock" style="text-align: center;"><%= record.attended ? "Yes" : "No" %></div>
                        <% end %>
                      <% end %>
                      <% if @event.event_type == "Committee" %>
                        <div class="cellBlock" style="text-align: center;"><%= record.attended ? "Yes" : "No" %></div>
                      <% end %>

                      <% if ((session[:user].admin) or (session[:user].id == @event.mic_id)) %>

                          <% if (@event.event_type == "Service" or @event.event_type == "Indy Hours" or @event.event_type == "Office Hour")%>
                            <% if Event.isBefore(@event.date, Time.now) %>
                              <div class="cellBlock" style="text-align: center;"><%= link_to "edit hours attended", :action => "edit_attendee_hours", :event_id => @event, :id => @event, :member_id => member.id %></div>
                            <% end %>
                          <% end %>
                              <div class="cellBlock" style="text-align: center;"><%= check_box_tag 'selected[]', member.id %></div>

                      <% end %>

                  </div>

                  <% row = row + 1 %>

              <% end %>

          </div>

        <% end %>

        <% waitlist = AttendanceRecord.find(:all, :conditions => {:event_id => @event, :waitlist => 1}, :order => "id ASC") %>
        <% if waitlist.size > 0 %>
            <h3> Waitlist </h3>

            <div class="container attendeeContainer">

                <div class="cellRow cellRowHeader">
                    <div class="cellBlock">#</div>
                    <div class="cellBlock">Attendee</div>
                    <div class="cellBlock">Email</div>
                    <div class="cellBlock" style="text-align: right;">Phone Number</div>
                    <% if (@event.event_type == "Service" or @event.event_type == "Fellowship" or @event.event_type == "Leadership" or @event.event_type == "Fundraiser" or @event.event_type == "Other" or (@event.event_type == "Pledge Req" and @event.drivers > 0)) %>
                        <div class="cellBlock">Driver</div>
                    <% end %>
                    <% if ((session[:user].admin) or (session[:user].id == @event.mic_id)) %>
                        <div class="cellBlock">&nbsp;</div>
                    <% end %>
                </div>

                <% row = 0 %>
                <% waitlist.each do |record| %>

                    <% member = record.member %>

                    <div class="cellRow cellRow<%= row%2==0?1:2 %>">

                        <div class="cellBlock"><%= row + 1 %></div>
                        <div class="cellBlock"><%= link_to h(member.full_name), :controller => "members", :action => "show", :id => member %></div>
                        <div class="cellBlock"><%=h member.email %>&nbsp;</div>
                        <div class="cellBlock" style="text-align: right;"><%=h member.phone_number %>&nbsp;</div>
                        <% if (@event.event_type == "Service" or @event.event_type == "Fellowship" or @event.event_type == "Leadership" or @event.event_type == "Fundraiser" or @event.event_type == "Other" or (@event.event_type == "Pledge Req" and @event.drivers > 0)) %>

                            <% if ((session[:user].admin) or (session[:user].id == @event.mic_id) or (member.id ==session[:user].id and Event.isBefore(Time.now, @event.date))) %>
                                <% if (record.driver == false) %>
                                    <div class="cellBlock" style="text-align: center;"><%= link_to "No <i>change</i>", :action => "driver_true", :record_id => record, :event_id => @event, :id => @event %></div>
                                <% else %>
                                    <div class="cellBlock" style="text-align: center;"><%= link_to "Yes <i>change</i>", :action => "driver_false", :record_id => record, :event_id => @event, :id => @event %></div>
                                <% end %>
                            <% else %>
                                <div class="cellBlock" style="text-align: center;">
                                    <% if (record.driver)%>
                                        Yes
                                    <% else %>
                                        No
                                    <% end %>
                                </div>
                            <% end %>

                        <% end %>

                        <% if ((session[:user].admin) or (session[:user].id == @event.mic_id)) %>

                            <div class="cellBlock" style="text-align: center;"><%= link_to "remove", :action => "remove_attendee", :event_id => @event, :id => @event, :member_id => member.id %></div>

                        <% end %>

                    </div>

                    <% row = row + 1 %>

                <% end %>

            </div>

        <% end %>

        <h5> Attendees' Email Addresses (For the MIC to email them) </h5>
        <h7>
<!--             attendees = Member.find(:all, :select => "members.*", :conditions => ["members.id in (select member_id from attendance_records where event_id =#{@event.id} and waitlist = 0)"], :order => "last_name, first_name ASC") -->
            <% attendees = AttendanceRecord.find_all_by_event_id(@event.id, :conditions => {:waitlist => 0}) %>
            <% num_attendees = attendees.size - 1 %>
            <% attendees.each_with_index do |attendee, index| %>
                <%= attendee.member.email != "" ? attendee.member.email : "" %><%= index < num_attendees ? ", " : "" %>
            <% end %>
        </h7>

    </div>

</div>
